/**
 * 素材管理页面js
 * 版权所有：上海戈品投资管理有限公司
 *   author wang
     功能说明：素材管理
     创建日期：2015-10-20
     修改记录：
     备注说明：
 */

$(document).ready(function() {
	wxMsgContentList();
});


/**
 * 消息列表
 * @returns
 */
var wxMsgContentList = function(){
	//var datas =  {"p":"wxMsgManage","m":"query","senderNickName":senderNickName,"sendType":sendType,"sendStatus":sendStatus,"checkTime":checkTime,"TimeType":TimeType};
	var datas = {"p":"wxMsgManage","m":"queryMaterialList","type":"image"};
	var columnDefine = {"media_id":"媒体ID","name":"素材名称","update_time":"更新时间","url":"素材存放路径"};
	
	var formatters={
	            "media_id":function (column, rowData){
	            	return '<input type="checkbox" value="'+rowData.media_id+'" class="select-box" name="select">';
	            },
	            
	            "update_time": function (column, rowData)
	            {
	            	var newTime= new Date(rowData.update_time*1000);
	            	var rowText=newTime.getFullYear()+'-'+getTheSureTime((newTime.getMonth()+1))+'-'
	            	+getTheSureTime(newTime.getDate())+' '+getTheSureTime(newTime.getHours())+':'
	            	+getTheSureTime(newTime.getMinutes())+':'+getTheSureTime(newTime.getSeconds());
	            	return rowText;
	            },
	            "url": function (column, rowData)
	            {
       				
    				return '<img style="width:120px" src="'+rowData.url+'">';
	            }
	 };
		var buttons =''; //操作按钮
		buttons+='<p>';
		buttons+='</p>';
	   hui.pager('service',datas ,"dataList", columnDefine , formatters , buttons ); //分页查询
	
};

function getTheSureTime(emp){
	return emp>9?emp:"0"+emp;
}


var getMaterialList=function(){
	 var datas = {"p":"wxMsgManage","m":"queryMaterialList","type":"image"};
	  var json = common.ajaxRequest('service', datas ,'POST');
	  if( json && json.result == 0 )
	  {
		  
		 
	  }
};
var showUploadMaterial=function(){
	$('#uploadMaterial').modal('show');
	resetUploadMaterial();
};
/**
 * 重置上传图片
 * @returns
 */
var resetUploadMaterial=function(){
	$("#uploadImgText").attr("src","/osc/page?p=page/uploadImgToWx");
};
/**
 * 上传图片完成
 * @returns
 */
var uploadMaterialOK=function(){
	window.location.reload();
};
/**
 * 删除素材	第一步
 */
var delMaterial=function(){
	
};
/**
 * 删除素材	第二步
 */
var delMaterialOperate=function(mediaId){
	
};

